package com.byt.common.view.refresh;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.TypedValue;

import com.byt.base.utils.TimeUtil;
import com.byt.common.R;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.util.DensityUtil;

import java.text.SimpleDateFormat;
import java.util.Locale;

/**
 * 经典下拉头部
 * Created by SCWANG on 2017/5/28.
 */
public class RefreshHeaderView extends ClassicsHeader {

    public static String REFRESH_HEADER_UPDATE = "上次更新 " + TimeUtil.dateFormatYMDHM;//"上次更新 yyyy-MM-dd HH:mm";

    private Context mContext;

    public RefreshHeaderView(Context context) {
        this(context, null);
    }

    public RefreshHeaderView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public RefreshHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
    }

    public RefreshHeaderView getHeaderXmxbHome() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_user));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_user));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#ffdef3"));
        setAccentColor(Color.parseColor("#fdecf8"));
        mTitleText.setTextColor(Color.parseColor("#fcb5c3"));
        mLastUpdateText.setTextColor(Color.parseColor("#fcb5c3"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleUserWhite() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_user));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_user));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#ffffff"));
        setAccentColor(Color.parseColor("#ff487d"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleUserF5() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_user));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_user));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#f5f5f5"));
        setAccentColor(Color.parseColor("#ff487d"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleUserFF() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_white));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_white));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#ff698d"));
        setAccentColor(Color.parseColor("#ffffff"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleUserMain() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_white));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_white));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#ff487d"));
        setAccentColor(Color.parseColor("#ffffff"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleUserEC() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_white));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_white));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#ecc576"));
        setAccentColor(Color.parseColor("#ffffff"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleUserBD() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_white));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_white));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#bdc1ca"));
        setAccentColor(Color.parseColor("#ffffff"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleMainTransparent() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_white));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_white));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setAccentColor(Color.parseColor("#ffffff"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleExpertWhite() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_expert));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_expert));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#ffffff"));
        setAccentColor(Color.parseColor("#79d6db"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleExpertF5() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_expert));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_expert));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#f5f5f5"));
        setAccentColor(Color.parseColor("#79d6db"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleExpertMain() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_white));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_white));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#79d6db"));
        setAccentColor(Color.parseColor("#ffffff"));
        return this;
    }

    public RefreshHeaderView getHeaderStyleStaffMain() {
        mArrowView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.pull_icon_big_white));
        mProgressView.setImageDrawable(mContext.getResources().getDrawable(R.drawable.loading_progress_white));
        mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(16));
        mLastUpdateText.setTextSize(TypedValue.COMPLEX_UNIT_PX, DensityUtil.dp2px(12));
        setTimeFormat(new SimpleDateFormat(REFRESH_HEADER_UPDATE, Locale.getDefault()));
        setPrimaryColor(Color.parseColor("#5eb8ff"));
        setAccentColor(Color.parseColor("#ffffff"));
        return this;
    }
}